#ifndef STRAY_RESOURCE_H
#define STRAY_RESOURCE_H

#include <Object/Uncopyable.h>
#include <SmartPtr/SharedPtr.h>
#include <SmartPtr/WeakPtr.h>
#include <String/String.h>

namespace Stray {
namespace Resource {

class ResourceID
{
	friend size_t hash_value(const ResourceID& id);
	typedef Stray::String String;
public:
	ResourceID(
		const String& archiveName,
		const String& fileName,
		const String& resourceName,
		const String& type);

	bool operator ==(const ResourceID& rhs) const;
private:
	Uint32 hashValue_;
	Stray::String archiveName_;
	Stray::String fileName_;
	Stray::String resourceName_;
	Stray::String type_;
};

size_t hash_value(const ResourceID& id);

enum ResourceState
{
	RS_LOADED,
	RS_LOADING,
	RS_UNLOADED,
	RS_UNLOADING,

	RS_UNKNOWN,
};

class ResourceFile;
typedef Stray::WeakPtr<ResourceFile>::type ResFileRef;

class Resource : private Stray::Uncopyable
{
public:
	Resource(const ResourceID& id): id_(id), state_(RS_UNLOADED){}
	virtual ~Resource(){};
	ResourceState getState() const
	{
		return state_;
	}
	virtual void load(Bool isAsync = B_FALSE) = 0;
protected:
	ResourceID id_;
	ResourceState state_;
	ResFileRef wpFile_;
};

typedef Stray::SharedPtr<Resource>::type ResourcePtr;

}
}

#endif